package com.lottery.shadowbd.ui.fragment;


import android.content.Intent;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;

import com.lottery.shadowbd.R;
import com.lottery.shadowbd.ui.activity.WebActivity;
import com.lottery.shadowbd.adapter.NewsAdapter;
import com.lottery.shadowbd.bean.TestNews;
import com.lottery.shadowbd.callback.OnMyItemClickListener;
import com.lottery.shadowbd.support.Constant;
import com.lottery.shadowbd.support.SpacesItemDecoration;
import com.lottery.shadowbd.widget.PullLoadMoreRecyclerView;

import java.util.ArrayList;
import java.util.List;

/**
 * A simple {@link Fragment} subclass.
 * 彩票资讯
 */
public class LotteryInfoFragment extends BaseFragment implements PullLoadMoreRecyclerView.PullLoadMoreListener, OnMyItemClickListener {

    private View mView;

    private PullLoadMoreRecyclerView pull_load_news;

    private List<TestNews> mList;

    private NewsAdapter mNewsAdapter;

    @Override
    protected View initView(LayoutInflater inflater) {
        mView = inflater.inflate(R.layout.fragment_lottery_info, null);

        pull_load_news = (PullLoadMoreRecyclerView) mView.findViewById(R.id.pull_load_news);

        return mView;
    }

    @Override
    protected void initData() {
        mContext = getActivity();

        mList = new ArrayList<>();

        initList();

        mNewsAdapter = new NewsAdapter(mContext, mList);

        pull_load_news.setRefreshEnable(false);
        pull_load_news.setLinearLayout();
        pull_load_news.addItemDecoration(new SpacesItemDecoration(2));

        pull_load_news.setAdapter(mNewsAdapter);
    }

    @Override
    protected void listener() {
        pull_load_news.setmPullLoadMoreListener(this);
        mNewsAdapter.setMyItemClickListener(this);
    }

    @Override
    protected void widgetClick(View v) {

    }

    @Override
    public void onItemClick(View view, int position) {
        if(mList != null) {
            startActivity(new Intent(mContext, WebActivity.class).putExtra(Constant.KeyWebUrl,mList.get(position).getWebUrl()));
        }
    }

    @Override
    public void onRefresh() {

    }

    @Override
    public void onLoadMore() {

    }

    private void initList() {
        mList.add(new TestNews("幸运女神双色球第18025期推荐：看好小奇蓝球","2018年03月05日 11:54 新浪彩票","http://sports.sina.com.cn/l/2018-03-05/doc-ifxipenn0429393.shtml"));
        mList.add(new TestNews("碧云天双色球第18025期预测：稳杀红球11","2018年03月05日 11:25 新浪彩票","http://sports.sina.com.cn/l/2018-03-05/doc-ifxipenn0249114.shtml"));
        mList.add(new TestNews("乐心小天双色球第18025期预测：关注小奇蓝球","2018年03月05日 11:23 新浪彩票","http://sports.sina.com.cn/l/2018-03-05/doc-ifxipenn0232520.shtml"));
        mList.add(new TestNews("金拐双色球第18025期预测：红三胆10 13 30","2018年03月05日 10:09 新浪彩票","http://sports.sina.com.cn/l/2018-03-05/doc-ifxipenm9732762.shtml"));
        mList.add(new TestNews("财迷迷七星彩第18025期预测：首位号码看偶","2018年03月05日 11:53 新浪彩票","http://sports.sina.com.cn/l/2018-03-05/doc-ifxipenn0421560.shtml"));
        mList.add(new TestNews("安生七星彩第18025期投注策略：偶数末位待补","2018年03月05日 10:32 新浪彩票","http://sports.sina.com.cn/l/2018-03-05/doc-ifxipenm9886779.shtml"));
        mList.add(new TestNews("历史上的今天-双色球03月06日开奖号码汇总","2018年03月05日 09:31 新浪彩票","http://sports.sina.com.cn/l/2018-03-05/doc-ifxipenm9492875.shtml"));
        mList.add(new TestNews("紫萱双色球第18024期预测：红球胆码10 18 24","2018年03月04日 10:55 新浪彩票","http://sports.sina.com.cn/l/2018-03-04/doc-ifwnpcnt8729584.shtml"));
        mList.add(new TestNews("郭果大乐透第18024期预测：后区看01 04 09 12","2018年03月03日 13:25 新浪彩票","http://sports.sina.com.cn/l/2018-03-03/doc-ifwnpcnt5647787.shtml"));
        mList.add(new TestNews("老彩民20元中双色球822万 奖金替子女还贷","2018年03月02日 15:24 新浪彩票","http://sports.sina.com.cn/l/2018-03-02/doc-ifwnpcnt1930284.shtml"));
        mList.add(new TestNews("财迷迷七星彩第18024期预测：六位码看2路","2018年03月03日 13:05 新浪彩票","http://sports.sina.com.cn/l/2018-03-03/doc-ifwnpcnt5550041.shtml"));
        mList.add(new TestNews("常领双色球第18024期预测：土码推荐05 29 32","2018年03月03日 13:53 新浪彩票","http://sports.sina.com.cn/l/2018-03-03/doc-ifwnpcnt5781485.shtml"));
        mList.add(new TestNews("火烈鸟大乐透第18024期解析：上期命中3+1","2018年03月03日 13:24 新浪彩票", "http://sports.sina.com.cn/l/2018-03-03/doc-ifwnpcnt5642608.shtml"));
        mList.add(new TestNews("郭果大乐透第18024期预测：后区看01 04 09 12","2018年03月03日 13:25 新浪彩票","http://sports.sina.com.cn/l/2018-03-03/doc-ifwnpcnt5647787.shtml"));
        mList.add(new TestNews("天狼星七星彩第18024期预测：看好大号回补","2018年03月03日 15:43 新浪彩票","http://sports.sina.com.cn/l/2018-03-03/doc-ifwnpcnt6249068.shtml"));
        mList.add(new TestNews("http://caitong.sina.com.cn/n/ob/2018-02-28/doc-ifwnpcns3664594.shtml","2018年02月28日 17:46   新浪彩通","http://caitong.sina.com.cn/n/ob/2018-02-28/doc-ifwnpcns3664594.shtml"));
        mList.add(new TestNews("印制即开型彩票其实也是技术活","2018年02月24日 17:59   新浪彩通","http://caitong.sina.com.cn/n/ob/2018-02-24/doc-ifyrwsqh8125874.shtml"));
        mList.add(new TestNews("体彩福彩齐发力，即开票兑奖不再愁","2018年02月12日 17:44   新浪彩通","http://caitong.sina.com.cn/n/ob/2018-02-12/doc-ifyrpeie0290926.shtml"));
        mList.add(new TestNews("20年忠实彩民获福彩696万 领奖时激动到语无伦次","2018年03月04日 15:23 新浪彩票","http://sports.sina.com.cn/l/2018-03-04/doc-ifxipenm6944013.shtml"));
    }
}
